var config = require('../config');
var mongoose = require('mongoose');
var moment = require('moment');

//mongoose
var url = 'mongodb://' + config.host + '/' + config.db;
mongoose.connect(url, {
  user : config.user,
  pass : config.pwd
});

require('../models/user.js');
require('../models/category.js');
require('../models/store.js');

var User = mongoose.model('User');
var Category = mongoose.model('Category');
var Store = mongoose.model('Store');

Category.find().exec(function(err, cs){
    for(var i = 0; i < cs.length; i++){
        var c = cs[i];
        console.log(c);
        for(var j = 0; j < 20; j++){
            var store = new Store({
                category: c,
                text: '测试题库-' + i + '-' + j,
                profession : 'teacher', //适用职业,将多个职业名字拼接存储
                drill : 5, //参加该题库的练习，可得积分数
                score : 10, //参加该题库的挑战，第一名可得积分数
                duration: 15, // 最大挑战时间 单位为: 秒
                bounty: 100
            });
            store.save(function(err){
                console.log(store);
            })
        }
    }
});


